package com.mrx.xfriendship.controller;

import com.mrx.commons.annotations.XLog;
import com.mrx.xfriendship.service.ICaptchaService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码 接口
 *
 * @author Mr.X
 * @since 2023-01-14 11:23
 */
@XLog
@RestController
public class CaptchaController {

    @DubboReference
    private ICaptchaService captchaService;

    /**
     * 获取 验证码 图片
     *
     * @param t 随机 验证码 key
     * @return 验证码图片
     */
    @GetMapping(value = "/captcha", produces = MediaType.IMAGE_JPEG_VALUE)
    public byte[] captcha(@RequestParam String t) {
        return captchaService.getCaptcha(t);
    }

}
